<template>
  <view class="reviews-stat-card">
    <view class="reviews-stat">
      <view class="reviews-stat__header">
        <text class="reviews-stat__rating">{{ rating.toFixed(1) }}</text>
        <view class="reviews-stat__stars">
          <text 
            v-for="i in 5" 
            :key="i" 
            class="reviews-stat__star" 
            :class="{ 'active': i <= Math.round(rating) }"
          >★</text>
        </view>
      </view>
      <view class="reviews-stat__text">{{ count }}条评价 · {{ goodRate }}%好评率</view>
    </view>
  </view>
</template>

<script setup>
defineProps({
  rating: {
    type: Number,
    default: 0
  },
  count: {
    type: Number,
    default: 0
  },
  goodRate: {
    type: Number,
    default: 0
  }
});
</script>

<style lang="scss" scoped>
.reviews-stat-card {
  background-color: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.reviews-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
}

.reviews-stat__header {
  display: flex;
  align-items: baseline;
  margin-bottom: 8px;
}

.reviews-stat__rating {
  font-size: 28px;
  font-weight: 600;
  color: #333;
  margin-right: 10px;
}

.reviews-stat__stars {
  display: flex;
}

.reviews-stat__star {
  font-size: 18px;
  color: #e0e0e0;
  margin-right: 2px;
  
  &.active {
    color: #ffbc00;
  }
}

.reviews-stat__text {
  font-size: 14px;
  color: #666;
}
</style>
